<?php
/**
 *
 *精彩瞬间控制器
 *
 **/
namespace Home\Controller;

use Vendor\Page;

class WonderfulMomentController extends ComController
{

    /*
     * 精彩瞬间列表
     */
    public  function   index(){

        $sc_id = I('uid') ?  I('uid') : 0 ;
        $wonderful_moment = M('wonderful_moment');
        $data = $wonderful_moment->where('sc_id ='.$sc_id)->select();

        $this->assign('data',$data);
        $this->display('moment');

    }


    /*
     * 精彩瞬间详情
     */
  public   function  detail(){

      $id = I('id') ? I('id') : 0;
      $wonderful_moment = M('wonderful_moment');
      $data= $wonderful_moment->join('as w left join  sc_class  as c    on w.class_id=c.id')
          ->field('w.id, w.title, w.content, w.picture, w.class_id, w.add_time, c.name, c.class_manager, c.class_teacher, c.life_teacher,c.class_type')
          ->where('w.id ='.$id)
          ->find();

      $member = M('member');

      if($data['class_manager']){
          //班主任
          $class_manager = $member->where('uid ='.$data['class_manager'])->find();
          $data['manager_name']=$class_manager['name'];
      }

      if($data['class_teacher']){
          //配班老师
          $class_teacher = $member->where('uid ='.$data['class_teacher'])->find();
          $data['teacher_name']=$class_teacher['name'];
      }

      if($data['life_teacher']){
          //生活老师
          $life_teacher = $member->where('uid ='.$data['life_teacher'])->find();
          $data['life_name']=$life_teacher['name'];
      }

      if($data['class_type']){
          //班级类型
          $class_type = M('class_type');
          $type=  $class_type->where('id ='.$data['class_type'])->find();
          $data['type']=$type['name'];
      }

      //当前时间
      $data['time']=time();

      $this->assign('data',$data);
      $this->display('moment-content');

  }











}